import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p002 from './p002';
import p003 from './p003';
export default async function a001(fd: IFeidaoAiBrowserComponent) {
	// todo

	const s = fd.data.node.querySelector<HTMLSelectElement>('[data-id="xm"]').value;
	const res = await nodejs<{ dt2: Array<{}>; }>('inventory-of-assets/zj-000002/s002', {
		filter: {
			project_no: s
		}
	});
	if (res.dt2.length <= 0) {
		alert("该项目名称没有值，无法添加");
		fire('zj-000002','a004');
		return;

	}
	const dataNo = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p002"]');
	const data = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p003"]');
	if (s.length > 0) {
		render(fd, res.dt2, p002, 'p002', 'inner');
		dataNo.style.display = "block";
		data.style.display = "none";
	}
	if (res.dt2.length === 0) {
		render(fd, res.dt2, p003, 'p003', 'inner');
		data.style.display = "block";
	}
}
